<?php

namespace App\HttpController\Web;

use App\HttpController\BaseController;
use App\Model\CategorysDaModel;
use App\Model\CategorysModel;
use App\Model\FormIds;
use App\Model\VideosDaduizhangModel;
use App\Task\ArticleTask;
use App\Utility\Cache;
use EasySwoole\Component\Pool\PoolManager;
use EasySwoole\EasySwoole\Config;
use App\Utility\Pool\MysqlPool;
use App\Utility\MiniProgram;
use Carbon\Carbon;
use EasySwoole\EasySwoole\Swoole\Task\TaskManager;

/**
 * @title 首页
 * @description 首页控制器
 * @method GET
 * @request go
 * @param int id 文章ID true 0
 * @param string code 验证码 false ''
 * @return int code 状态码（0成功1失败）
 * @return string msg 提示信息
 * @return int userid 用户ID
 * @example {title: "首页",description: "首页控制器",method: "GET",request: "https://baby.chumomei.com/go"}
 */
class IndexController extends BaseController {

    public function index(){
        $cache = new Cache();
//        $model = new VideosDaduizhangModel();
//        $list = $model->get();
//        foreach ($list as $item){
//            $cache->sAdd('daduizhang_video_data',json_encode($item));
//        }
        $data = $cache->sRandMember('daduizhang_video_data',50);
        return $this->writeJson(0,['num'=>$cache->scard('daduizhang_video_data'),'data'=>$data],'要割鸡鸡的，@-@');
        return $this->writeJson(0,'偷看数据怎么办？','要割鸡鸡的，@-@');
    }

    /**
     * 测试
     * @return bool
     */
    public function test(){
        return $this->writeJson(1,'这是测试go');
    }

    /**
     * 统计每个小程序当月counts表
     */
    public function count()
    {
        $Cache = new Cache();
        $result = $Cache->get('statistics_counts');
        return $this->writeJson(0, $result, '');
    }

    /**
     * 统计每个小程序当日countDay表
     */
    public function countDay()
    {
        $Cache = new Cache();
        $result = $Cache->get('statistics_counts_day');
        return $this->writeJson(0, $result, '');
    }

    public function photo()
    {
        $index = [
            'bgUrl' => 'http://applet.xiegangsir.com/2019-03-21/a834edf985dec1e9605a00f0ded9ae1d.png',
            'imgTop' => 'http://applet.xiegangsir.com/2019-03-21/e6db9f350233117e6b8e8c16170dcc7c.png',
            'logo' => 'http://applet.xiegangsir.com/2019-03-21/f338e83ef87c106ccac9e94025a0dfc8.png',
            'day' => '今天是3月21日',
            'time' => '下午好',
            'blessing' => '给您送来祝福'
        ];

        $list = [
            [
                'top_left' => 'http://applet.xiegangsir.com/2019-03-21/34c788a0a5853b8646975a4f26f6a6df.png',
                'top_center' => '',
                'top_right' => 'http://applet.xiegangsir.com/2019-03-21/a7ed687df7af0a69f266c84f0ea45336.png',
                'center_left' => '',
                'center_center' => '',
                'center_right' => '',
                'bottom_left' => '',
                'bottom_center' => 'http://applet.xiegangsir.com/2019-03-21/e77c120ea50c83c1d539521cdbe264ea.png',
                'bottom_right' => 'http://applet.xiegangsir.com/2019-03-21/8bec889a2bd1aadeea058cf1108a9839.png',
                'top' => '',
                'right' => '',
                'bottom' => 'http://applet.xiegangsir.com/2019-03-21/5c4e58ede0c4a89e8833d514d4a34c2c.png',
                'left' => '',
                'text1' => '提的起,放得下,路在脚下向前跨',
                'text2' => '天不来，地不来，自己动手才能来',
                'text3' => '短不了，长不了，活着就要心态好',
                'text4' => '一不贪，二不抢，做人一定凭良心',
                'text5' => '',
                'text6' => '',
                'text7' => '',
                'bgUrl' => 'http://applet.xiegangsir.com/2019-03-21/cdc9a303b0ccdb7579d866405d839b9d.jpg',
            ]
        ];

        $result = ['index' => $index, 'list' => $list];
        return $this->writeJson(0, $result, '');
    }
}
